# include <bits/stdc++.h>
using namespace std;

struct node { 
    bool cnt;
    node *ne[26];
    vector <int> cd;
    int dp;
    node() {;}
} *root;

void insert(char str[]) { 
    int i = 0, index;
    node *p = root;
    while(str[i]) { 
        index = str[i] - 'a';
        if(p->ne[index]) { 
            p = p->ne[index];
        } else { 
            p->cd.push_back(index);
            p = p->ne[index] = new node();
        }
        i++;
    }
    p->cnt = 1;
}

int dp(node *x) { 
    int mx = 0;
    int siz = x->cd.size();
    for(int i = 0; i < siz; i++) { 
        mx = max(mx, dp(x->ne[x->cd[i]]));
    }
    return mx + x->cnt;
}

char temp[55];

int main() { 
# ifndef LOCAL
    freopen("link.in", "r", stdin);
    freopen("link.out", "w", stdout);
# endif
    root = new node();
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) { 
        scanf("%s", temp);
        insert(temp);
    }
    printf("%d\n", dp(root));
}
